//const Mock = require('mockjs')
import Mock from 'mockjs'
const Random = Mock.Random


let Result = {
    code: 200,
    msg: '操作成功!',
    data: null,
}

Mock.mock('/captcha', 'get', () => {

    Result.data = {
        token: Random.string(32),
        captchaImg: Random.dataImage('120x40', 'p7n5w')
    }

    return Result
})


Mock.mock('/login', 'post', () => {


    return Result
})

Mock.mock('/sys/userInfo', 'get', () => {

    Result.data = {
        id: '1',
        username: 'test',
        avatar: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
    }


    return Result
})

Mock.mock('/logout', 'post', () => {

    return Result
})

Mock.mock('/sys/menu/list', 'get', () => {
    let menus = [
        {
            id: 1,
            date: '2016-05-02',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1518 弄',
            statu: 1,
            type: 1
        },
        {
            id: 2,
            date: '2016-05-04',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1517 弄',
            type: 0
        },
        {
            id: 3,
            date: '2016-05-01',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1519 弄',
            type: 2,
            children: [
                {
                    id: 31,
                    date: '2016-05-01',
                    name: '王小虎555',
                    address: '上海市普陀区金沙江路 1519 弄',
                    type: 1
                },
                {
                    id: 32,
                    date: '2016-05-01',
                    name: '王小虎666',
                    address: '上海市普陀区金沙江路 1519 弄'
                }]
        },
        {
            id: 4,
            date: '2016-05-03',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1516 弄'
        }
    ]
    Result.data = menus
    return Result
})
Mock.mock('/sys/menu/delete','delete',(id)=>{
    return Result
})
Mock.mock('/sys/menu/info/','get',(id)=>{
    let res = {
        "id": 1,
        "title": "系统管理",
        "icon": "el-icon-s-operation",
        "path": "",
        "name": "sys:manage",
        "component": "1",
        "parentId":"1",
        "region":'1',
        "perms":'1',
        "type":"1",
        "statu":'1',
        "orderNum":"1",
    }
    Result.data = res
    return Result
})
Mock.mock('/sys/menu/nav', 'get', () => {

    let nav = [{
        "id": 1,
        "title": "系统管理",
        "icon": "el-icon-s-operation",
        "path": "",
        "name": "sys:manage",
        "component": "",
        "children": [{
            "id": 2,
            "title": "用户管理",
            "icon": "el-icon-s-custom",
            "path": "/sys/users",
            "name": "sys:user:list",
            "component": "sys/User",
            "children": []
        }, {
            "id": 3,
            "title": "角色管理",
            "icon": "el-icon-rank",
            "path": "/sys/roles",
            "name": "sys:role:list",
            "component": "sys/Role",
            "children": []
        }, {
            "id": 4,
            "title": "菜单管理",
            "icon": "el-icon-menu",
            "path": "/sys/menus",
            "name": "sys:menu:list",
            "component": "sys/Menu",
            "children": []
        }]
    }, {
        "id": 5,
        "title": "系统工具",
        "icon": "el-icon-s-tools",
        "path": "",
        "name": "sys:tools",
        "component": null,
        "children": [{
            "id": 6,
            "title": "数字字典",
            "icon": "el-icon-s-order",
            "path": "/sys/dicts",
            "name": "sys:dict:list",
            "component": "sys/Dict",
            "children": []
        }]
    }]

    let authoritys = [
        'sys:user:list',
        'sys:user:save',
        'sys:user:delete',
    ]

    Result.data = {
        nav: nav,
        authoritys: authoritys
    }

    return Result
})
